package io.github.mayubao.kotlintest

import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Test

class Day4_WhenTest{

    @Test
    fun testWhen(){
        val i = "hello"

        val result = testWhenDemo(i)


        assertEquals("hello world", result);
    }

    /**
     * test when method
     */
    fun testWhenDemo(i : Any ?) : Any?{
        var result : Any;
        when(i) {
            "1" -> result = "11"
            "2" -> result =  "22"
            "hello" -> result =  "hello world"
            3 -> result =  "test"

            else -> {
                result = ""
            }
        }
        return result
    }
}